#include "sc_test.h"

#ifdef _TEST
BEGIN_K3D
struct mathTest:public testing::Test
{
	void SetUp()
	{
		randomSet(m1,dm1);
		for (int i=0;i<100;i++)
		{
			farr[i]=randomFloat(); 
		}
		for (int i=0;i<10;i++)
		{
			randomSet(vecs[i],dvecs[i]);
		}
		for (int i=0;i<10;i++)
		{
			randomSet(vecList[i],dvecList[i]);
		}
	}
	void TearDown()
	{

	}
	Matrix m1;
	D3DXMATRIX dm1;
	Vector3 vecs[10];
	D3DXVECTOR3 dvecs[10];
	Vector vecList[10];
	D3DXVECTOR4 dvecList[10];
	float farr[100];

};
TEST_F(mathTest,scale)
{
	MatrixScale(&m1,farr[0],farr[1],farr[2]);
	D3DXMatrixScaling(&dm1,farr[0],farr[1],farr[2]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
//TODO 
TEST_F(mathTest,scaleAxis)
{
}
TEST_F(mathTest,RotationXYZ)
{
	MatrixRotationX(&m1,farr[0]);
	D3DXMatrixRotationX(&dm1,farr[0]);
	EXPECT_TRUE(KEqual(m1,dm1));
	MatrixRotationY(&m1,farr[1]);
	D3DXMatrixRotationY(&dm1,farr[1]);
	EXPECT_TRUE(KEqual(m1,dm1));
	MatrixRotationZ(&m1,farr[2]);
	D3DXMatrixRotationZ(&dm1,farr[2]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
//TODO
TEST_F(mathTest,rotationAsix)
{

}
TEST_F(mathTest,translation)
{
	MatrixTranslation(&m1,farr[0],farr[1],farr[2]);
	D3DXMatrixTranslation(&dm1,farr[0],farr[1],farr[2]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
TEST_F(mathTest,lookatLH)
{
	MatrixLookAtLH(&m1,vecs,vecs+1,vecs+2);
	D3DXMatrixLookAtLH(&dm1,dvecs,dvecs+1,dvecs+2);
	EXPECT_TRUE(KEqual(m1,dm1));
}
TEST_F(mathTest,perspectiveOffCenterLH)
{
	MatrixPerspectiveOffCenterLH(&m1,farr[0],farr[1],farr[2],farr[3],farr[4],farr[5]);
	D3DXMatrixPerspectiveOffCenterLH(&dm1,farr[0],farr[1],farr[2],farr[3],farr[4],farr[5]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
TEST_F(mathTest,perspectiveFovLH)
{
 	MatrixPerspectiveFovLH(&m1,farr[0],farr[1],farr[2],farr[3]);
 	D3DXMatrixPerspectiveFovLH(&dm1,farr[0],farr[1],farr[2],farr[3]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
TEST_F(mathTest,OrthoOffCenterLH)
{
	MatrixOrthoOffCenterLH(&m1,farr[0],farr[1],farr[2],farr[3],farr[4],farr[5]);
	D3DXMatrixOrthoOffCenterLH(&dm1,farr[0],farr[1],farr[2],farr[3],farr[4],farr[5]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
TEST_F(mathTest,OrthoLH)
{
	MatrixOrthoLH(&m1,farr[0],farr[1],farr[2],farr[3]);
	D3DXMatrixOrthoLH(&dm1,farr[0],farr[1],farr[2],farr[3]);
	EXPECT_TRUE(KEqual(m1,dm1));
}
TEST_F(mathTest,vectorTransform)
{
	VectorTransform(vecList,vecList,&m1);
	D3DXVec4Transform(dvecList,dvecList,&dm1);
	EXPECT_TRUE(KEqual(*vecList,*dvecList));
}
TEST_F(mathTest,vector3TransformCoord)
{
	Vector3transformCoord(vecs,vecs,&m1);
	D3DXVec3TransformCoord(dvecs,dvecs,&dm1);
	EXPECT_TRUE(KEqual(*vecs,*dvecs));
}
TEST_F(mathTest,vector3Transform)
{
	Vector3transform(vecList,vecs,&m1);
	D3DXVec3Transform(dvecList,dvecs,&dm1);
	EXPECT_TRUE(KEqual(*vecList,*dvecList));
}
END_K3D
#endif